<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/component/pear/css/pear.css"/>
    <link rel="stylesheet" href="/admin/css/other/department.css"/>
    <link rel="stylesheet" href="/admin/css/other/console2.css"/>
    <style>
        .pear-card-title {
            display: flex;
            justify-content: center;
            flex-direction: row;
            flex-wrap: nowrap;
        }

        .pear-card {
            display: flex;
            align-items: center;
            justify-content: center
        }

        .layui-form-select dl {
            max-height: 250px;
            top: 42px;
            bottom: unset;
        }

        .pear-btn i {
            font-size: 14px;
        }

        .layui-form-label {
            width: 90px;
        }

        .pear-btn-md {
            height: 38px;
            line-height: 38px;
            font-size: 13px;
        }
    </style>
</head>
<body class="pear-container">
<div class="layui-row layui-col-space10">
    <div class="layui-col-md12">
        <div class="layui-card">
            <div class="layui-card-header">
                开门操作
            </div>
            <div class="layui-card-body">
                <form class="layui-form" action="" onsubmit="return false">
                    <div class="layui-form-item" style="display: flex;">
                        <label class="layui-form-label">机柜编号:</label>
                        <div class="layui-input-inline">
                            <select name="hostId" lay-verify="required" lay-reqtext="请选择机柜" lay-search>
                                <option value="">请选择层</option>
                                <option th:each="host : ${hostList}" th:value="${host.id}"
                                        th:text="${host.number}"></option>
                            </select>
                        </div>
                        <div class="layui-form-item layui-inline" style="display: flex">
                            <button class="pear-btn pear-btn-md pear-btn-primary" lay-submit
                                    style="display: flex;flex-direction: row;align-items: center;margin-right: 12px;"
                                    lay-filter="openTheDoor">
                                <img src="/img/开门.svg" alt="" style="width: 22px;height: 22px;margin-right: 5px;">
                                开门
                            </button>
                            <button class="pear-btn pear-btn-md" lay-submit style="display: flex;flex-direction: row;align-items: center;margin-right: 12px;
                            background-color: #1e9fff !important;border: 1px solid #1e9fff !important;color: white;"
                                    lay-filter="inventoryStorage">
                                <img src="/img/盘库.svg" alt="" style="width: 22px;height: 22px;margin-right: 5px;">
                                单个盘库
                            </button>
                            <button class="pear-btn pear-btn-md" style="display: flex;flex-direction: row;align-items: center;
 background-color: #1e9fff !important;border: 1px solid #1e9fff !important;color: white;" id="allInventoryStorage">
                                <img src="/img/盘库.svg" alt="" style="width: 22px;height: 22px;margin-right: 5px;">
                                全部盘库
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script src="/component/layui/layui.js"></script>
<script src="/component/pear/pear.js"></script>
<script>
    layui.use(['form', 'jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;

        $("#allInventoryStorage").click(function () {
            reqeustUtil('/motor/manual/all/inventoryStorage', {"tyoe": "all"})
        });

        function reqeustUtil(url, data) {
            let loading = layer.load();
            $.ajax({
                url: url,
                dataType: 'json',
                contentType: "application/json;charset=utf-8",
                type: "POST",
                data: JSON.stringify(data.field),
                success: function (result) {
                    layer.close(loading);
                    if (result.code === 200) {
                        layer.msg(result.message, {icon: 1, time: 3000});
                    } else {
                        layer.msg(result.message, {icon: 2, time: 3000});
                    }
                }
            })
        }

        // 开门操作
        form.on('submit(openTheDoor)', function (data) {
            reqeustUtil('/motor/manual/open/door', data)
            return false;
        });
        // 盘库操作
        form.on('submit(inventoryStorage)', function (data) {
            reqeustUtil('/motor/manual/inventoryStorage', data)
            return false;
        });
    })
</script>


</body>
</html>